package com.shaohai.live.utils;

import com.google.gson.Gson;
import com.shaohai.live.entity.ApiPostTaskParams;

import java.util.concurrent.TimeUnit;

import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

public class HttpRequestUtils {
    private static OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).build();
    private static Gson gson = new Gson();

    public static void postAsync(ApiPostTaskParams taskParams, Callback callback) {
        RequestBody body = RequestBody.create(AppDefine.JSON, taskParams.getJsonString());
        Request request = new Request.Builder().url(taskParams.url).post(body).build();
        httpClient.newCall(request).enqueue(callback);
    }
}
